import Vue from 'vue'
import VueRouter from 'vue-router'

const Tabbar = () => import('@/components/Tabbar.vue')
const Home = () => import('@/views/Home')
const Question = () => import('@/views/Question')
const Video = () => import('@/views/Video')
const User = () => import('@/views/User')
const Artcile = () => import('@/views/Article')
const Login = () => import('@/views/Login')
const Search = () => import('@/views/Search')
const SearchRes = () => import('@/views/SearchRes')

Vue.use(VueRouter)

const routes = [
  // 路由规则
  { path: '/', components: { default: Home, tabbar: Tabbar } },
  { path: '/question', components: { default: Question, tabbar: Tabbar } },
  { path: '/video', components: { default: Video, tabbar: Tabbar } },
  { path: '/user', components: { default: User, tabbar: Tabbar } },
  { path: '/article/:article_id', component: Artcile },
  { path: '/login', component: Login },
  { path: '/search', component: Search },
  { path: '/searchRes', component: SearchRes }
]

const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  next()
})
export default router
